home *** CD-ROM | disk | FTP | other *** search
- Path: Rezonet.net!news
- From: ray@ultimate-tech.com (Ray Dunn)
- Newsgroups: comp.lang.c
- Subject: Re: Q: Getting data from a FAR CHAR * buffer: HELP!
- Date: 25 Jan 1996 16:09:15 GMT
- Organization: Ultimate Technographics Inc.
- Message-ID: <4e89vc$ehg@ns.RezoNet.NET>
- References: <4e7208$iqb@dingo.cc.uq.oz.au>
- NNTP-Posting-Host: 204.19.230.7
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
- In referenced article, coonsta@peg.apc.org says...
- >
- >typedef struct pcx_picture_typ
- >{
- > pcx_header header; //Forget it: it's irrelevant
- > RGB_color pallette[256]; //Forget this too.
- > char far *buffer; //That's the one.
- >} pcx_picture, *pcx_picture_pointer;
- >
- >Every pcx_picture is initalised with this call, which allocates memory
- >for the buffer. I don't think it makes any difference, but here 'tis:
- >
- >void PCX_Init(pcx_picture_ptr image)
- >{
- > image->buffer = (char far *)_fmalloc(64000);
- >}
- >
- >void main(void)
- >{
- > int x;
- > pcx_picture thepicture;
- >
- > . (The buffer is initialised and filled with data from a
- > . file in here).
- > .
- >
- > x = thepicture.buffer[32000]; // doesn't seem to work.
- >}
-
- There doesn't seem to be anything wrong with this code fragment, so I
- would suspect that your problem is perhaps in the filling of the buffer
- from the file.
-
- Test it with a text file and write a little test loop outputting each
- character from the buffer. You should see your text file getting
- printed.
-
- [system specific response warning]
-
- In this case your problem may be with the system specific "far"
- declaration. I'm always suspicious when I see it's use, because you
- only need "far" if you're compiling in small or medium model. If that
- is the case, then you cannot call read or fread with a pointer to that
- far buffer because these library routine expect a near pointer in these
- models (at least MSC). Are you ignoring some compiler warnings?
-
- If you're compiling in large model, you don't need to use "far" because
- all pointers are far. I strongly recommend that if you need to create
- far data, then use large model and you can then forget about all these
- issues - and it has the advantage that you can then post code without
- being yelled at for using non-conforming keywords like "far"!
-
- Further discussion of this topic should go to a DOS or Windows
- newsgroup.
- --
- Ray Dunn (opinions are my own) | Phone: (514) 938 9050
- Montreal | Phax : (514) 938 5225
- ray@ultimate-tech.com | Home : (514) 630 3749
-
-